#include <math.h>
#include <iostream>
using std::cout;
using std::endl;

/* class Point2; */
/* class Point2{}; */



class Point{
public:
    Point(int x,int y)
        : _ix(x)
          , _iy(y)
    { cout << "point(int,int)" << endl; }

    //友元声明
    /* friend Line; */
    friend class Line;
private:
    int _ix;
    int _iy;
};

class Line{
public:
    Line(const Point & pt,const Point & pt2);

    float distance(const Point & lhs,const Point & rhs);

    void setPoint(Point & pt,int x,int y);

private:
    Point _pt;
    Point _pt2;
};

//这几个成员函数都可以放到Line类中实现
Line::Line(const Point & pt,const Point & pt2)
: _pt(pt)
, _pt2(pt2)
{}

float Line::distance(const Point & lhs,const Point & rhs){
    return sqrt(pow(lhs._ix - rhs._ix,2)+ 
                pow(lhs._iy - rhs._iy,2));
}

void Line::setPoint(Point & pt,int x,int y){
    pt._ix = x;
    pt._iy = y;
}

void test0(){
    Point pt(0,0);
    Point pt2(3,4);
    Line ll(pt,pt2);
    cout << ll.distance(pt,pt2) << endl;
    ll.setPoint(pt2,12,5);
    cout << ll.distance(pt,pt2) << endl;

    /* Point2 pt; */
}

int main(void){
    test0();
    return 0;
}
